package stud.aistar.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import stud.aistar.vo.MedicineVo;

import java.util.List;

/**
 * *
 *
 * @ClassName :wangyu
 * @Description
 * @Author
 * @Date2019/9/28 11:20
 * @Version V1.0
 */
public interface MedicineVoMapper {
    //查询所有药品
    @Select("<script>" +
            "select m.*,mt.type_name FROM medicine m JOIN  medtype mt on m.medtype_id = mt.id"+
            "<where>"+
            "<if test = 'med_name != null'>"+
            "and med_name like concat('%',#{medName},'%')"+
            "</if>"+
            "</where>"+
            "</script>")
    List<MedicineVo> findAll(String medName);
    //分类查询

    List<MedicineVo> findMedicine(@Param("name") String medName,@Param("price") String medPrice,@Param("typeId") Integer medTypeId);

    @Select("select m.*,mt.type_name FROM medicine m JOIN  medtype mt on m.medtype_id = mt.id where med_name like concat('%',#{medName},'%')")
    List<MedicineVo> findByMedName(String medName);

    @Select("select m.*,mt.type_name FROM medicine m JOIN  medtype mt on m.medtype_id = mt.id where illmed_id = #{ids}")
    List<MedicineVo> findByIllmedId(@Param("ids") Integer illmedId);

}
